package com.trex.modules.tbl.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.trex.modules.tbl.entity.TblZdLjzyqdz;
import com.trex.modules.tbl.service.TblZdLjzyqdzService;

/**
 * 列检作业区对照Controller
 * @author jy
 * @version 2022-09-05
 */
@Controller
@RequestMapping(value = "/tbl/tblZdLjzyqdz")
public class TblZdLjzyqdzController extends BaseController {

	@Autowired
	private TblZdLjzyqdzService tblZdLjzyqdzService;
	
	/**
	 * 获取数据
	 */
	@ModelAttribute
	public TblZdLjzyqdz get(String recId, boolean isNewRecord) {
		return tblZdLjzyqdzService.get(recId, isNewRecord);
	}
	
	/**
	 * 查询列表
	 */
	//@RequiresPermissions("tbl:tblZdLjzyqdz:view")
	@RequestMapping(value = {"list", ""})
	public String list(TblZdLjzyqdz tblZdLjzyqdz, Model model) {
		model.addAttribute("tblZdLjzyqdz", tblZdLjzyqdz);
		return "modules/tbl/tblZdLjzyqdzList";
	}
	
	/**
	 * 查询列表数据
	 */
	//@RequiresPermissions("tbl:tblZdLjzyqdz:view")
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<TblZdLjzyqdz> listData(TblZdLjzyqdz tblZdLjzyqdz, HttpServletRequest request, HttpServletResponse response) {
		tblZdLjzyqdz.setPage(new Page<>(request, response));
		Page<TblZdLjzyqdz> page = tblZdLjzyqdzService.findPage(tblZdLjzyqdz);
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	//@RequiresPermissions("tbl:tblZdLjzyqdz:view")
	@RequestMapping(value = "form")
	public String form(TblZdLjzyqdz tblZdLjzyqdz, Model model) {
		model.addAttribute("tblZdLjzyqdz", tblZdLjzyqdz);
		return "modules/tbl/tblZdLjzyqdzForm";
	}

	/**
	 * 保存数据
	 */
	//@RequiresPermissions("tbl:tblZdLjzyqdz:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated TblZdLjzyqdz tblZdLjzyqdz) {
		tblZdLjzyqdzService.save(tblZdLjzyqdz);
		return renderResult(Global.TRUE, text("保存列检作业区对照成功！"));
	}
	
	/**
	 * 删除数据
	 */
	//@RequiresPermissions("tbl:tblZdLjzyqdz:edit")
	@RequestMapping(value = "delete")
	@ResponseBody
	public String delete(TblZdLjzyqdz tblZdLjzyqdz) {
		tblZdLjzyqdzService.delete(tblZdLjzyqdz);
		return renderResult(Global.TRUE, text("删除列检作业区对照成功！"));
	}
	
}